package com.itwlj.mapper;

import com.itwlj.entity.Banner;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface BannerMapper {

    /**
     * 新增轮播图
     *
     * @param banner
     */
    @Insert("insert into banner(img_url, distribution_site) values (#{imgUrl},#{distributionSite})")
    void insert(Banner banner);

    /**
     * 查询轮播图
     *
     * @return
     */
    @Select("select * from banner group by distribution_site, id")
    List<Banner> list();

    /**
     * 根据id删除轮播图
     *
     * @param id
     */
    @Delete("delete from banner where id = #{id}")
    void deleteById(Long id);

    /**
     * 根据id修改轮播图
     *
     * @param banner
     */
    @Update("update banner set img_url = #{imgUrl} ,distribution_site = #{distributionSite} where id = #{id}")
    void update(Banner banner);

    /**
     * 根据分发站点查询轮播图
     *
     * @param distributionSite
     * @return
     */
    @Select("select * from banner where distribution_site = #{distributionSite}")
    List<Banner> getByDistributionSite(Integer distributionSite);
}
